package com.handinglian.ai.common.component;

import com.handinglian.ai.notice.service.NoticeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.io.IOException;

@Component
@Slf4j
public class ScheduledTasks {
    @Autowired
    private NoticeService noticeService;

    @Scheduled(cron = "0 * * * * *")
    @Transactional
    public void censusNotice() throws IOException {
        try {
            noticeService.censusNotice();
        } catch (Exception e){
            log.error("人口普查通知异常");
            throw e;
        }

    }
}
